<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>按键修饰符</title>
    <script src="lib/vue.js"></script>
</head>

<body>
    <div id="box">
        原生js按键修饰符<br>
        <input type="text" @keyup="handleKeyup($event)">
        <hr>

        vue按键修饰符<br>
        <input type="text" @keyup.enter="handleEnter()">

        <hr>
        如果特殊的按键，可以使用键值<br>
        <input type="text" @keyup.13="handleEnter()">

    </div>

    <script>
        new Vue({
            el: "#box",
            data: {

            },
            methods: {
                handleKeyup(ev) {
                    console.log(ev);
                    if (ev.keyCode === 13) {
                        console.log("enter - 执行了动作");
                    }
                },
                handleEnter() {
                    console.log("vue-按键修饰符");
                }
            }
        })
    </script>

</body>

</html>